package com.example.springboot.controller;


import com.example.springboot.pojo.User;
import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@Slf4j
public class testController {

    @GetMapping("/rj2221")
    public void test1(String name,Integer id){
        System.out.println(name+"=="+id);
    }

    @GetMapping("/rj2222")
    public void test2(HttpServletRequest httpServletRequest){

        String name = httpServletRequest.getParameter("name");
        String id = httpServletRequest.getParameter("id");

        System.out.println(name+"=="+id);
    }
    @GetMapping("/rj2223")
    public void test3(@RequestParam("name") String nm, @RequestParam("id") Integer i){
        System.out.println(nm+"=="+i);
    }


    @GetMapping("/rj2224/{name}/{id}")
    public void test4(@PathVariable("name") String name, @RequestParam("id") Integer id){

        System.out.println(name+"=="+id);
    }


    @GetMapping("/rj2225")
    public void test4(User user){
        System.out.println(user.toString());
    }

    @PostMapping("/user/register")
    public User RegisterTest5(@RequestBody User user){
        System.out.println(user.toString());
        return user;
    }

    @GetMapping("/user/list")
    public List idList(@RequestParam("id") List ids){
        log.info("接收到数组{}",ids);

        return ids;
    }

    @GetMapping("/user/map")
    public Map<String, String> idList(Map<String,String> map){
        log.info("接收到数组{}",map);
        return map;
    }
}
